//
//  Array+Extension.swift
//  
//
//  Created by Hoa on 2020/12/31.
//

import Foundation

public extension Array where Self.Element == (key: String, value: Any) {
    
    /**
     * k1=v1&k2=v2
     */
    func kvString() -> String {
        
        var kvs = ""
        self.forEach { (item) in
            kvs += "\(item.key)=\(item.value)&"
        }
        if kvs.count > 0 {
            kvs.removeLast()
        }
        
        if kvs.contains("\\") {
            kvs = kvs.replacingOccurrences(of: "\\", with: "")
        }
        
        return kvs
    }
    
}
